<?php
namespace Topxia\Service\Kuke\Impl;

use Topxia\Common\ArrayToolkit;
use Topxia\Service\Common\BaseService;
use Topxia\Service\Kuke\ActiveMaService;

class ActiveMaServiceImpl extends BaseService implements ActiveMaService
{
	public function getActiveMa($conditions,$start,$limit)
	{
		return $this->getActiveMaDao()->getActiveMa($conditions,$start,$limit);
	}
	public function buildding($conditions)
	{
		return $this->getActiveMaDao()->buildding($conditions);
	}
	public function getActiveMaCount($conditions)
	{
		return $this->getActiveMaDao()->getActiveMaCount($conditions);
	}
	public function set($conditions)
	{
		return $this->getActiveMaDao()->set($conditions);
	}
	public function reset($conditions)
	{
		return $this->getActiveMaDao()->reset($conditions);
	}
	
	public function activing($conditions)
	{
		return $this->getActiveMaDao()->activing($conditions);
	}

	public function getstatus($activema)
	{
		return $this->getActiveMaDao()->getstatus($activema);
	}

	public function gettrystatus($conditions)
	{
		return $this->getActiveMaDao()->gettrystatus($conditions);
	}
	
	public function trying($conditions,$ip){
		if($this->getUserService()->getUserByLoginField($conditions['xingming'])){
			return array("status"=>"err","message"=>"此姓名已存在","id"=>3);
		}else if($this->getUserService()->getUserByLoginField($conditions['email'])){
			return array("status"=>"err","message"=>"此E-mail已存在","id"=>3);
		}else{
			$formData = array();
			$formData['email']			= $conditions['email'];
			$formData['mobile']			= $conditions['mobile'];
			$formData['emailOrMobile']	= $conditions['mobile'];
			$formData['nickname']		= $conditions['xingming'];
			$formData['password']		= $conditions['mobile'];
			$formData['type']			= 'activema';
			$formData['createdIp']		= $ip;
			$this->getAuthService()->register($formData);
		}

		return $this->getActiveMaDao()->trying($conditions);
	}
	public function getactivemaByMachine($conditions){
		return $this->getActiveMaDao()->getactivemaByMachine($conditions);
	}
	public function gettrylist($conditions,$start,$limit){
		return $this->getActiveMaDao()->gettrylist($conditions,$start,$limit);
	}
	public function gettryCount($conditions)
	{
		return $this->getActiveMaDao()->gettryCount($conditions);
	}

	//曹乾
	public function select(){
		return $this->getActiveMaDao()->select();
	}
	public function updateActiveMa($id)
	{
		return $this->getActiveMaDao()->updateActiveMa($id);
	}

	protected function getActiveMaDao()
	{
		return $this->createDao('Kuke.ActiveMaDao');
	}

    protected function getAuthService()
    {
        return $this->createService('User.AuthService');
    }

    protected function getUserService()
    {
        return $this->createService('User.UserService');
    }



}